/**
 * Created by dqw on 2015/12/30.
 */

// 银行卡列表开始
var dtGridColumnsAdmin = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery: true,
        'export': false,
        hideQueryType: 'eq',
        hideQueryValue: 1,
        hide: true
    },
    {
        id: 'id',
        title: '管理员ID',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'name',
        title: '管理员姓名',
        type: 'string',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: false,
    },
    {
        id: 'operation',
        title: '管理操作',
        type: 'string',
        'export': false,
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        extra: false,
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            return "<a href='javascript:;' class='btn btn-danger btn-sm m-r-10' onclick='BindHandle.delInfo(" + record.id + ",\"" + record.name + "\")'><i class='fa fa-ban'></i>&nbsp;删除&nbsp;</a>";
        }
    }
];


var dtGridOptionAdmin = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'admin/json/list',
    columns: dtGridColumnsAdmin,
    gridContainer: 'dtGridContainerAdmin',
    pageSize: 50,
    pageSizeLimit: [10, 20, 50]
};

var grid2 = $.fn.DtGrid.init(dtGridOptionAdmin);
grid2.fastQueryParameters = new Object();
grid2.fastQueryParameters['eq_delFlag'] = 1;
grid2.fastQueryParameters['eq_buss_id'] = GetQueryString("investorId");


function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

//操作处理开始
var BindHandle = function () {
    function _bindEvent() {

    }

    //删除标的内容
    var delUrl = ncGlobal.adminRoot + "admin/json/del";

    function _delInfo(id, content) {
        var tpl = '您选择对模拟投资人绑定的管理员<strong>' + content + '</strong> 进行删除操作，删除后将无法恢复。<br/>您确定要进行删除操作吗?'
        $.ncConfirm({
            url: delUrl,
            data: {
                id: id
            },
            backType:1,
            content: tpl,
            alertTitle: "删除操作",
            callBack:function () {
                grid2.refresh(true);
            }
        });
    }
    //外部可调用
    return {
        bindEvent: _bindEvent,
        delInfo: _delInfo
    }
}();
//操作处理结束

$(function () {
    //页面绑定事件
    BindHandle.bindEvent();
    grid2.load();
});